package com.foreveross.fetl.util;

import java.util.concurrent.atomic.AtomicInteger;

public class RandomUtils extends org.apache.commons.lang.math.RandomUtils{

	
	public static Integer nextRandom(int min, int max){
		int r = org.apache.commons.lang.math.RandomUtils.nextInt(max);
		while(r < min){
			r = org.apache.commons.lang.math.RandomUtils.nextInt(max);
		}
		return r;
	}
	
    private static AtomicInteger counter = new AtomicInteger(0);

    /**
     * 长生消息id
     */
    public static long getAtomicCounter() {
        if (counter.get() > 999999) {
            counter.set(1);
        }
        long time = System.currentTimeMillis();
        long returnValue = time * 10000 + counter.incrementAndGet()*100 +nextRandom(10,100);
        return returnValue;
    }

}
